﻿using Cysharp.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawner : MonoBehaviour
{
    public GameObject prefab;
    public bool auto;
    // Start is called before the first frame update
    async void Start()
    {
        if (auto)
        {
            while (true)
            {
                int time = Random.Range(300, 1500);
                await UniTask.Delay(time);
                Instantiate(prefab);
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Instantiate(prefab);
        }


    }
}
